/*
package com.atguigu.controller;

import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Ref;

import java.io.IOException;
import java.util.List;

public class GitUtilClass {
    public static String localRepoPath = "D:/repo";
    public static String localRepoGitConfig = "D:/repo/.git";
    public static String remoteRepoURI = "git@gitlab.com:wilson/test.git";
    public static String localCodeDir = "D:/platplat";
    */
/*** 新建一个分支并同步到远程仓库
     *@parambranchName

    *@throwsIOException

      *@throwsGitAPIException*//*


public static String newBranch(String branchName){

        String newBranchIndex= "refs/heads/"+branchName;

        String gitPathURI= "";

        Git git;try{//检查新建的分支是否已经存在，如果存在则将已存在的分支强制删除并新建一个分支

        List refs =git.branchList().call();for(Ref ref : refs) {if(ref.getName().equals(newBranchIndex)) {undefined

        System.out.println("Removing branch before");

        git.branchDelete().setBranchNames(branchName).setForce(true)

        .call();break;

        }

        }
        //新建分支

        Ref ref =git.branchCreate().setName(branchName).call();//推送到远程

        git.push().add(ref).call();

        gitPathURI= remoteRepoURI + " " + "feature/" +branchName;

        }catch(IOException e) {//TODO Auto-generated catch block

        e.printStackTrace();

        }catch(GitAPIException e) {//TODO Auto-generated catch block

        e.printStackTrace();

        }

        }

        public static void commitFiles() throwsIOException, GitAPIException{undefined

        String filePath= "";

        Git git= Git.open( newFile(localRepoGitConfig) );//创建用户文件的过程

        File myfile = newFile(filePath);

        myfile.createNewFile();

        git.add().addFilepattern("pets").call();//提交

        git.commit().setMessage("Added pets").call();//推送到远程

        git.push().call();

        }public static booleanpullBranchToLocal(String cloneURL){boolean resultFlag = false;

        String[] splitURL= cloneURL.split(" ");

        String branchName= splitURL[1];

        String fileDir= localCodeDir+"/"+branchName;//检查目标文件夹是否存在

        File file = newFile(fileDir);if(file.exists()){undefined

        deleteFolder(file);

        }

        Git git;try{undefined

        git= Git.open( newFile(localRepoGitConfig) );

        git.cloneRepository().setURI(cloneURL).setDirectory(file).call();

        resultFlag= true;

        }catch(IOException e) {//TODO Auto-generated catch block

        e.printStackTrace();

        }catch(GitAPIException e) {//TODO Auto-generated catch block

        e.printStackTrace();

        }returnresultFlag;

        }public static voiddeleteFolder(File file){if(file.isFile() || file.list().length==0){undefined

        file.delete();

        }else{undefined

        File[] files=file.listFiles();for(int i=0;i

        deleteFolder(files[i]);

        files[i].delete();

        }

        }

        }public static void setupRepo() throwsGitAPIException{//建立与远程仓库的联系，仅需要执行一次

        Git git = Git.cloneRepository().setURI(remoteRepoURI).setDirectory(newFile(localRepoPath)).call();

        }

        }
*/
